package belote.model.jeu;

public enum Figure {

	AS("1", "as", 11, 11, 8, 14),   //
	ROI("K", "roi", 4, 4, 6, 12),   //
	DAME("Q", "dame", 3, 3, 5, 11), //
	VALLET("J", "vallet", 2, 20, 4, 16), //
	DIX("10", "dix", 10, 10, 7, 13), //
	NEUF("9", "neuf", 0, 14, 3, 15), //
	HUIT("8", "huit", 0, 0, 2, 10), //
	SEPT("7", "sept", 0, 0, 1, 9); //
	
	// -------------------------------------------------------------- Attributs
	
	private String code;
	
	private String libelle;
	
	private int points;
	
	private int pointsAtout;
	
	private int valeur;
	
	private int valeurAtout;
	
	// ----------------------------------------------------------- Constructeur
	
	private Figure(String pCode, String pLibelle, int pPoints, int pPointsAtout, int pValeur, int pValeurAtout) {

		this.code = pCode;
		this.libelle = pLibelle;
		this.points = pPoints;
		this.pointsAtout = pPointsAtout;
		this.valeur = pValeur;
		this.valeurAtout = pValeurAtout;
	}
	
	// ----------------------------------------------------- Methodes publiques
	
	public static Figure getFigure(String pCode) {
		
		for (Figure figure : values()) {
			if (figure.getCode().equals(pCode)) {
				return figure;
			}
		}
		
		throw new IllegalArgumentException("Impossible de retrouver la figure pour le code : " + pCode);
	}
	
	// ---------------------------------------------------------------- Getters
	
	public String getCode() {
		return code;
	}
	
	public String getLibelle() {
		return libelle;
	}
	
	public int getPoints() {
		return points;
	}
	
	public int getPointsAtout() {
		return pointsAtout;
	}
	
	public int getValeur() {
		return valeur;
	}
	
	public int getValeurAtout() {
		return valeurAtout;
	}
}
